package com.shiwaixiangcun.monitor.dto;

import com.shiwaixiangcun.core.web.context.strategy.AbstractCtrlReturnValueHandler;
import com.shiwaixiangcun.core.web.response.ResponseEntity;

import java.util.Map;

/**
 * Created by Administrator on 2017-11-27.
 */
public class WorkHandler extends AbstractCtrlReturnValueHandler {
    @Override
    public boolean support(Object returnValue) {
        return returnValue instanceof WorkOrderListDto;
    }

    @Override
    public ResponseEntity handle(Object returnValue, String fieldStr) {
        WorkOrderListDto extendedDto = (WorkOrderListDto) returnValue;
        Map data = this.exportResultPage(fieldStr, extendedDto.getWorkOrderDtos());
        data.put("allWork", extendedDto.getAllWork());
        data.put("commitedWork", extendedDto.getCommitedWork());
        data.put("timeoutWork", extendedDto.getTimeoutWork());
        data.put("acceptedWork",extendedDto.getAcceptedWork());
        return new ResponseEntity().success(data);
    }
}
